import axios from '../serve/axios'

// 登录
export const login = (uname, pwd) => axios({
  method: 'post',
  url: 'users/login',
  data: {
    uname,
    pwd
  }
})

// 轮播图
export const getCarousel = () => axios({
  method: 'post',
  url: 'homes/swipe',
  data: {}
})

// 主页菜单
export const getMenu = () => axios({
  method: 'post',
  url: 'homes/menu',
  data: {}
})

// 主页资讯
export const getInfo = () => axios({
  method: 'post',
  url: 'homes/info',
  data: {}
})

// 主页问答
export const getFaq = () => axios({
  method: 'post',
  url: 'homes/faq',
  data: {}
})

// 主页分类房屋信息
export const getHouse = () => axios({
  method: 'post',
  url: 'homes/house',
  data: {}
})

// 房屋列表信息
export const getHouseList = (home_type) => axios({
  method: 'post',
  url: 'homes/list',
  data: {
    home_type
  }
})

// 主页地图
export const getMap = () => axios({
  method: 'post',
  url: 'homes/map',
  data: {}
})

// 资讯列表
export const getList = (pagenum, pagesize, type) => axios({
  method: 'post',
  url: 'infos/list',
  data: {
    pagenum,
    pagesize,
    type
  }
})

// 问题列表
export const getQuestion = (question) => axios({
  method: 'post',
  url: 'infos/question',
  data: {
    question
  }
})

// 聊天用户列表
export const getChatList = () => axios({
  method: 'post',
  url: 'chats/list',
  data: {}
})

// 聊天信息
export const getChatInfo = (from_user, to_user) => axios({
  method: 'post',
  url: 'chats/info',
  data: {
    from_user,
    to_user
  }
})

// 个人信息
export const getUserInfo = (user_id) => axios({
  method: 'post',
  url: 'my/info',
  data: {
    user_id
  }
})

// 更改头像
export const changeAvatar = (avatar) => axios({
  method: 'post',
  url: 'my/avatar',
  data: {
    avatar
  }
})
